import ContextMenu from "@imengyu/vue3-context-menu";

// http://vue3-context-menu-docs.imengyu.top/

export default (event: MouseEvent, isTop = false) => {
  event.preventDefault();

  let { x, y } = event;

  if (isTop) {
    x -= 4;
    y += 12;
  }

  ContextMenu.showContextMenu({
    x,
    y,
    items: [
      {
        label: "A menu item",
        icon: "iocnfont icon-shengchengdaima",
        onClick: () => {
          console.log("You click a menu item");
        }
      },
      {
        label: "A submenu",
        icon: "iconfont icon-json",
        children: [{ label: "Item1", icon: "iconfont icon-fangdajing" }, { label: "Item2" }, { label: "Item3" }]
      }
    ]
  });
};
